package com.kjlink.internal.report4vue.group;

import cn.xuqiudong.common.base.model.BaseResponse;
import cn.xuqiudong.common.base.model.PageInfo;
import com.kjlink.internal.report4vue.base.controller.BaseApiController;
import com.kjlink.internal.workreport.group.model.Group;
import com.kjlink.internal.workreport.group.service.GroupService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 描述:
 *
 * @author Vic.xu
 * @since 2024-12-03 16:13
 */
@RestController
public class ApiGroupController extends BaseApiController {

    @Resource
    private GroupService groupService;

    /**
     * 列表页
     */
    @RequestMapping(value = "/group/list", method = {RequestMethod.GET, RequestMethod.POST})
    public BaseResponse<PageInfo<Group>> index(@RequestBody Group lookup) {
        PageInfo<Group> pager = groupService.page(lookup);
        return BaseResponse.success(pager);
    }

    /**
     * 保存
     */
    @PostMapping("/group/save")
    public BaseResponse<String> save(@RequestBody Group entity) {
        groupService.save(entity);
        return BaseResponse.success();
    }

    /**
     * 删除
     */
    @PostMapping("/group/delete/{id}")
    public BaseResponse<String> delete(@PathVariable int id) {
        return groupService.checkAndDelete(id);
    }

}
